<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>octant.extern.poly_editor</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="octant-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="octant-module.html">Package&nbsp;octant</a> ::
        <a href="octant.extern-module.html">Package&nbsp;extern</a> ::
        Module&nbsp;poly_editor
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
      </table>
    </td>
  </tr>
</table>
<h1 class="epydoc">Source Code for <a href="octant.extern.poly_editor-module.html">Module octant.extern.poly_editor</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-docstring">This is an example to show how to build cross-GUI applications using</tt> </tt>
<a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-docstring">matplotlib event handling to interact with objects on the canvas</tt> </tt>
<a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">matplotlib</tt><tt class="py-op">.</tt><tt class="py-name">artist</tt> <tt class="py-keyword">import</tt> <tt class="py-name">Artist</tt> </tt>
<a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">matplotlib</tt><tt class="py-op">.</tt><tt class="py-name">patches</tt> <tt class="py-keyword">import</tt> <tt class="py-name">Polygon</tt><tt class="py-op">,</tt> <tt class="py-name">CirclePolygon</tt> </tt>
<a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">numpy</tt> <tt class="py-keyword">import</tt> <tt id="link-0" class="py-name" targets="Variable octant.extern.poly_editor.sqrt=octant.extern.poly_editor-module.html#sqrt,Variable octant.ocean.depths.sqrt=octant.ocean.depths-module.html#sqrt,Variable octant.ocean.sqrt=octant.ocean-module.html#sqrt,Variable octant.ocean.state.sqrt=octant.ocean.state-module.html#sqrt,Variable octant.ocean.step3d_t.sqrt=octant.ocean.step3d_t-module.html#sqrt,Variable octant.ocean.time.sqrt=octant.ocean.time-module.html#sqrt,Variable octant.ocean.velocity.sqrt=octant.ocean.velocity-module.html#sqrt"><a title="octant.extern.poly_editor.sqrt
octant.ocean.depths.sqrt
octant.ocean.sqrt
octant.ocean.state.sqrt
octant.ocean.step3d_t.sqrt
octant.ocean.time.sqrt
octant.ocean.velocity.sqrt" class="py-name" href="#" onclick="return doclink('link-0', 'sqrt', 'link-0');">sqrt</a></tt><tt class="py-op">,</tt> <tt class="py-name">nonzero</tt><tt class="py-op">,</tt> <tt id="link-1" class="py-name" targets="Variable octant.extern.poly_editor.equal=octant.extern.poly_editor-module.html#equal,Variable octant.ocean.depths.equal=octant.ocean.depths-module.html#equal,Variable octant.ocean.equal=octant.ocean-module.html#equal,Variable octant.ocean.state.equal=octant.ocean.state-module.html#equal,Variable octant.ocean.step3d_t.equal=octant.ocean.step3d_t-module.html#equal,Variable octant.ocean.time.equal=octant.ocean.time-module.html#equal,Variable octant.ocean.velocity.equal=octant.ocean.velocity-module.html#equal"><a title="octant.extern.poly_editor.equal
octant.ocean.depths.equal
octant.ocean.equal
octant.ocean.state.equal
octant.ocean.step3d_t.equal
octant.ocean.time.equal
octant.ocean.velocity.equal" class="py-name" href="#" onclick="return doclink('link-1', 'equal', 'link-1');">equal</a></tt><tt class="py-op">,</tt> <tt class="py-name">asarray</tt><tt class="py-op">,</tt> <tt class="py-name">dot</tt><tt class="py-op">,</tt> <tt class="py-name">amin</tt> </tt>
<a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">matplotlib</tt><tt class="py-op">.</tt><tt class="py-name">mlab</tt> <tt class="py-keyword">import</tt> <tt class="py-name">dist_point_to_segment</tt> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line"> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"> </tt>
<a name="PolygonInteractor"></a><div id="PolygonInteractor-def"><a name="L12"></a><tt class="py-lineno"> 12</tt> <a class="py-toggle" href="#" id="PolygonInteractor-toggle" onclick="return toggle('PolygonInteractor');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="octant.extern.poly_editor.PolygonInteractor-class.html">PolygonInteractor</a><tt class="py-op">:</tt> </tt>
</div><div id="PolygonInteractor-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="PolygonInteractor-expanded"><a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
<a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-docstring">    An polygon editor.</tt> </tt>
<a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-docstring">    Key-bindings</tt> </tt>
<a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line"><tt class="py-docstring">      't' toggle vertex markers on and off.  When vertex markers are on,</tt> </tt>
<a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line"><tt class="py-docstring">          you can move them, delete them</tt> </tt>
<a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt class="py-docstring">      'd' delete the vertex under point</tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"><tt class="py-docstring">      'i' insert a vertex at point.  You must be within epsilon of the</tt> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt>  <tt class="py-line"><tt class="py-docstring">          line connecting two existing vertices</tt> </tt>
<a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
<a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"> </tt>
<a name="L28"></a><tt class="py-lineno"> 28</tt>  <tt class="py-line">    <tt id="link-2" class="py-name" targets="Variable octant.extern.poly_editor.PolygonInteractor.showverts=octant.extern.poly_editor.PolygonInteractor-class.html#showverts"><a title="octant.extern.poly_editor.PolygonInteractor.showverts" class="py-name" href="#" onclick="return doclink('link-2', 'showverts', 'link-2');">showverts</a></tt> <tt class="py-op">=</tt> <tt class="py-name">True</tt> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line">    <tt id="link-3" class="py-name" targets="Variable octant.extern.poly_editor.PolygonInteractor.epsilon=octant.extern.poly_editor.PolygonInteractor-class.html#epsilon"><a title="octant.extern.poly_editor.PolygonInteractor.epsilon" class="py-name" href="#" onclick="return doclink('link-3', 'epsilon', 'link-3');">epsilon</a></tt> <tt class="py-op">=</tt> <tt class="py-number">5</tt>  <tt class="py-comment"># max pixel distance to count as a vertex hit</tt> </tt>
<a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line"> </tt>
<a name="PolygonInteractor.__init__"></a><div id="PolygonInteractor.__init__-def"><a name="L31"></a><tt class="py-lineno"> 31</tt> <a class="py-toggle" href="#" id="PolygonInteractor.__init__-toggle" onclick="return toggle('PolygonInteractor.__init__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="octant.extern.poly_editor.PolygonInteractor-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">ax</tt><tt class="py-op">,</tt> <tt class="py-param">poly</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PolygonInteractor.__init__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PolygonInteractor.__init__-expanded"><a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">figure</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line">            <tt class="py-keyword">raise</tt> <tt class="py-name">RuntimeError</tt><tt class="py-op">(</tt><tt class="py-string">'You must first add the polygon to a figure or canvas before defining the interactor'</tt><tt class="py-op">)</tt> </tt>
<a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">ax</tt> <tt class="py-op">=</tt> <tt class="py-name">ax</tt> </tt>
<a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line">        <tt class="py-name">canvas</tt> <tt class="py-op">=</tt> <tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">figure</tt><tt class="py-op">.</tt><tt class="py-name">canvas</tt> </tt>
<a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt> <tt class="py-op">=</tt> <tt class="py-name">poly</tt> </tt>
<a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line"> </tt>
<a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line">        <tt id="link-4" class="py-name" targets="Variable octant.grid.BoundaryInteractor.x=octant.grid.BoundaryInteractor-class.html#x,Variable octant.grid.CGrid.x=octant.grid.CGrid-class.html#x"><a title="octant.grid.BoundaryInteractor.x
octant.grid.CGrid.x" class="py-name" href="#" onclick="return doclink('link-4', 'x', 'link-4');">x</a></tt><tt class="py-op">,</tt> <tt id="link-5" class="py-name" targets="Variable octant.grid.BoundaryInteractor.y=octant.grid.BoundaryInteractor-class.html#y,Variable octant.grid.CGrid.y=octant.grid.CGrid-class.html#y"><a title="octant.grid.BoundaryInteractor.y
octant.grid.CGrid.y" class="py-name" href="#" onclick="return doclink('link-5', 'y', 'link-5');">y</a></tt> <tt class="py-op">=</tt> <tt class="py-name">zip</tt><tt class="py-op">(</tt><tt class="py-op">*</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt><tt class="py-op">)</tt> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt> <tt class="py-op">=</tt> <tt class="py-name">Line2D</tt><tt class="py-op">(</tt><tt id="link-6" class="py-name"><a title="octant.grid.BoundaryInteractor.x
octant.grid.CGrid.x" class="py-name" href="#" onclick="return doclink('link-6', 'x', 'link-4');">x</a></tt><tt class="py-op">,</tt><tt id="link-7" class="py-name"><a title="octant.grid.BoundaryInteractor.y
octant.grid.CGrid.y" class="py-name" href="#" onclick="return doclink('link-7', 'y', 'link-5');">y</a></tt><tt class="py-op">,</tt><tt class="py-name">marker</tt><tt class="py-op">=</tt><tt class="py-string">'o'</tt><tt class="py-op">,</tt> <tt class="py-name">markerfacecolor</tt><tt class="py-op">=</tt><tt class="py-string">'r'</tt><tt class="py-op">,</tt> <tt class="py-name">animated</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">)</tt> </tt>
<a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">add_line</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt><tt class="py-op">)</tt> </tt>
<a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line">        <tt class="py-comment">#self._update_line(poly)</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt class="py-comment"></tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line">        <tt class="py-name">cid</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">add_callback</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-8" class="py-name" targets="Method octant.extern.poly_editor.PolygonInteractor.poly_changed()=octant.extern.poly_editor.PolygonInteractor-class.html#poly_changed"><a title="octant.extern.poly_editor.PolygonInteractor.poly_changed" class="py-name" href="#" onclick="return doclink('link-8', 'poly_changed', 'link-8');">poly_changed</a></tt><tt class="py-op">)</tt> </tt>
<a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_ind</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> <tt class="py-comment"># the active vert</tt> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line"> </tt>
<a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line">        <tt class="py-name">canvas</tt><tt class="py-op">.</tt><tt class="py-name">mpl_connect</tt><tt class="py-op">(</tt><tt class="py-string">'draw_event'</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-9" class="py-name" targets="Method octant.extern.poly_editor.PolygonInteractor.draw_callback()=octant.extern.poly_editor.PolygonInteractor-class.html#draw_callback"><a title="octant.extern.poly_editor.PolygonInteractor.draw_callback" class="py-name" href="#" onclick="return doclink('link-9', 'draw_callback', 'link-9');">draw_callback</a></tt><tt class="py-op">)</tt> </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line">        <tt class="py-name">canvas</tt><tt class="py-op">.</tt><tt class="py-name">mpl_connect</tt><tt class="py-op">(</tt><tt class="py-string">'button_press_event'</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-10" class="py-name" targets="Method octant.extern.poly_editor.PolygonInteractor.button_press_callback()=octant.extern.poly_editor.PolygonInteractor-class.html#button_press_callback"><a title="octant.extern.poly_editor.PolygonInteractor.button_press_callback" class="py-name" href="#" onclick="return doclink('link-10', 'button_press_callback', 'link-10');">button_press_callback</a></tt><tt class="py-op">)</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line">        <tt class="py-name">canvas</tt><tt class="py-op">.</tt><tt class="py-name">mpl_connect</tt><tt class="py-op">(</tt><tt class="py-string">'key_press_event'</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-11" class="py-name" targets="Method octant.extern.poly_editor.PolygonInteractor.key_press_callback()=octant.extern.poly_editor.PolygonInteractor-class.html#key_press_callback"><a title="octant.extern.poly_editor.PolygonInteractor.key_press_callback" class="py-name" href="#" onclick="return doclink('link-11', 'key_press_callback', 'link-11');">key_press_callback</a></tt><tt class="py-op">)</tt> </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line">        <tt class="py-name">canvas</tt><tt class="py-op">.</tt><tt class="py-name">mpl_connect</tt><tt class="py-op">(</tt><tt class="py-string">'button_release_event'</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-12" class="py-name" targets="Method octant.extern.poly_editor.PolygonInteractor.button_release_callback()=octant.extern.poly_editor.PolygonInteractor-class.html#button_release_callback"><a title="octant.extern.poly_editor.PolygonInteractor.button_release_callback" class="py-name" href="#" onclick="return doclink('link-12', 'button_release_callback', 'link-12');">button_release_callback</a></tt><tt class="py-op">)</tt> </tt>
<a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line">        <tt class="py-name">canvas</tt><tt class="py-op">.</tt><tt class="py-name">mpl_connect</tt><tt class="py-op">(</tt><tt class="py-string">'motion_notify_event'</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-13" class="py-name" targets="Method octant.extern.poly_editor.PolygonInteractor.motion_notify_callback()=octant.extern.poly_editor.PolygonInteractor-class.html#motion_notify_callback"><a title="octant.extern.poly_editor.PolygonInteractor.motion_notify_callback" class="py-name" href="#" onclick="return doclink('link-13', 'motion_notify_callback', 'link-13');">motion_notify_callback</a></tt><tt class="py-op">)</tt> </tt>
<a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">canvas</tt> <tt class="py-op">=</tt> <tt class="py-name">canvas</tt> </tt>
</div><a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line"> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line"> </tt>
<a name="PolygonInteractor.draw_callback"></a><div id="PolygonInteractor.draw_callback-def"><a name="L54"></a><tt class="py-lineno"> 54</tt> <a class="py-toggle" href="#" id="PolygonInteractor.draw_callback-toggle" onclick="return toggle('PolygonInteractor.draw_callback');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="octant.extern.poly_editor.PolygonInteractor-class.html#draw_callback">draw_callback</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">event</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PolygonInteractor.draw_callback-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PolygonInteractor.draw_callback-expanded"><a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">background</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">canvas</tt><tt class="py-op">.</tt><tt class="py-name">copy_from_bbox</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">bbox</tt><tt class="py-op">)</tt> </tt>
<a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">draw_artist</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">)</tt> </tt>
<a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">draw_artist</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt><tt class="py-op">)</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">canvas</tt><tt class="py-op">.</tt><tt class="py-name">blit</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">bbox</tt><tt class="py-op">)</tt> </tt>
</div><a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line"> </tt>
<a name="PolygonInteractor.poly_changed"></a><div id="PolygonInteractor.poly_changed-def"><a name="L60"></a><tt class="py-lineno"> 60</tt> <a class="py-toggle" href="#" id="PolygonInteractor.poly_changed-toggle" onclick="return toggle('PolygonInteractor.poly_changed');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="octant.extern.poly_editor.PolygonInteractor-class.html#poly_changed">poly_changed</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">poly</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PolygonInteractor.poly_changed-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PolygonInteractor.poly_changed-expanded"><a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line">        <tt class="py-docstring">'this method is called whenever the polygon object is called'</tt> </tt>
<a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line">        <tt class="py-comment"># only copy the artist props to the line (except visibility)</tt> </tt>
<a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-name">vis</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt><tt class="py-op">.</tt><tt class="py-name">get_visible</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line">        <tt class="py-name">Artist</tt><tt class="py-op">.</tt><tt class="py-name">update_from</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt><tt class="py-op">,</tt> <tt class="py-name">poly</tt><tt class="py-op">)</tt> </tt>
<a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt><tt class="py-op">.</tt><tt class="py-name">set_visible</tt><tt class="py-op">(</tt><tt class="py-name">vis</tt><tt class="py-op">)</tt>  <tt class="py-comment"># don't use the poly visibility state</tt> </tt>
</div><a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line"> </tt>
<a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line"> </tt>
<a name="PolygonInteractor.get_ind_under_point"></a><div id="PolygonInteractor.get_ind_under_point-def"><a name="L68"></a><tt class="py-lineno"> 68</tt> <a class="py-toggle" href="#" id="PolygonInteractor.get_ind_under_point-toggle" onclick="return toggle('PolygonInteractor.get_ind_under_point');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="octant.extern.poly_editor.PolygonInteractor-class.html#get_ind_under_point">get_ind_under_point</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">event</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PolygonInteractor.get_ind_under_point-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PolygonInteractor.get_ind_under_point-expanded"><a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line">        <tt class="py-docstring">'get the index of the vertex under point if within epsilon tolerance'</tt> </tt>
<a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line"> </tt>
<a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line">        <tt class="py-comment"># display coords</tt> </tt>
<a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line"><tt class="py-comment"></tt>        <tt class="py-name">xy</tt> <tt class="py-op">=</tt> <tt class="py-name">npy</tt><tt class="py-op">.</tt><tt class="py-name">asarray</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt><tt class="py-op">)</tt> </tt>
<a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line">        <tt class="py-name">xyt</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">get_transform</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">transform</tt><tt class="py-op">(</tt><tt class="py-name">xy</tt><tt class="py-op">)</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line">        <tt class="py-name">xt</tt><tt class="py-op">,</tt> <tt class="py-name">yt</tt> <tt class="py-op">=</tt> <tt class="py-name">xyt</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">,</tt> <tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">xyt</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">,</tt> <tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line">        <tt class="py-name">d</tt> <tt class="py-op">=</tt> <tt id="link-14" class="py-name"><a title="octant.extern.poly_editor.sqrt
octant.ocean.depths.sqrt
octant.ocean.sqrt
octant.ocean.state.sqrt
octant.ocean.step3d_t.sqrt
octant.ocean.time.sqrt
octant.ocean.velocity.sqrt" class="py-name" href="#" onclick="return doclink('link-14', 'sqrt', 'link-0');">sqrt</a></tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-name">xt</tt><tt class="py-op">-</tt><tt class="py-name">event</tt><tt class="py-op">.</tt><tt id="link-15" class="py-name"><a title="octant.grid.BoundaryInteractor.x
octant.grid.CGrid.x" class="py-name" href="#" onclick="return doclink('link-15', 'x', 'link-4');">x</a></tt><tt class="py-op">)</tt><tt class="py-op">**</tt><tt class="py-number">2</tt> <tt class="py-op">+</tt> <tt class="py-op">(</tt><tt class="py-name">yt</tt><tt class="py-op">-</tt><tt class="py-name">event</tt><tt class="py-op">.</tt><tt id="link-16" class="py-name"><a title="octant.grid.BoundaryInteractor.y
octant.grid.CGrid.y" class="py-name" href="#" onclick="return doclink('link-16', 'y', 'link-5');">y</a></tt><tt class="py-op">)</tt><tt class="py-op">**</tt><tt class="py-number">2</tt><tt class="py-op">)</tt> </tt>
<a name="L76"></a><tt class="py-lineno"> 76</tt>  <tt class="py-line">        <tt class="py-name">indseq</tt> <tt class="py-op">=</tt> <tt class="py-name">nonzero</tt><tt class="py-op">(</tt><tt id="link-17" class="py-name"><a title="octant.extern.poly_editor.equal
octant.ocean.depths.equal
octant.ocean.equal
octant.ocean.state.equal
octant.ocean.step3d_t.equal
octant.ocean.time.equal
octant.ocean.velocity.equal" class="py-name" href="#" onclick="return doclink('link-17', 'equal', 'link-1');">equal</a></tt><tt class="py-op">(</tt><tt class="py-name">d</tt><tt class="py-op">,</tt> <tt class="py-name">amin</tt><tt class="py-op">(</tt><tt class="py-name">d</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> </tt>
<a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line">        <tt class="py-name">ind</tt> <tt class="py-op">=</tt> <tt class="py-name">indseq</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> </tt>
<a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line"> </tt>
<a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">d</tt><tt class="py-op">[</tt><tt class="py-name">ind</tt><tt class="py-op">]</tt><tt class="py-op">&gt;=</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-18" class="py-name"><a title="octant.extern.poly_editor.PolygonInteractor.epsilon" class="py-name" href="#" onclick="return doclink('link-18', 'epsilon', 'link-3');">epsilon</a></tt><tt class="py-op">:</tt> </tt>
<a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line">            <tt class="py-name">ind</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
<a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line"> </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">ind</tt> </tt>
</div><a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line"> </tt>
<a name="PolygonInteractor.button_press_callback"></a><div id="PolygonInteractor.button_press_callback-def"><a name="L84"></a><tt class="py-lineno"> 84</tt> <a class="py-toggle" href="#" id="PolygonInteractor.button_press_callback-toggle" onclick="return toggle('PolygonInteractor.button_press_callback');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="octant.extern.poly_editor.PolygonInteractor-class.html#button_press_callback">button_press_callback</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">event</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PolygonInteractor.button_press_callback-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PolygonInteractor.button_press_callback-expanded"><a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line">        <tt class="py-docstring">'whenever a mouse button is pressed'</tt> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-19" class="py-name"><a title="octant.extern.poly_editor.PolygonInteractor.showverts" class="py-name" href="#" onclick="return doclink('link-19', 'showverts', 'link-2');">showverts</a></tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> </tt>
<a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">inaxes</tt><tt class="py-op">==</tt><tt class="py-name">None</tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> </tt>
<a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">button</tt> <tt class="py-op">!=</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> </tt>
<a name="L89"></a><tt class="py-lineno"> 89</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_ind</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-20" class="py-name" targets="Method octant.extern.poly_editor.PolygonInteractor.get_ind_under_point()=octant.extern.poly_editor.PolygonInteractor-class.html#get_ind_under_point"><a title="octant.extern.poly_editor.PolygonInteractor.get_ind_under_point" class="py-name" href="#" onclick="return doclink('link-20', 'get_ind_under_point', 'link-20');">get_ind_under_point</a></tt><tt class="py-op">(</tt><tt class="py-name">event</tt><tt class="py-op">)</tt> </tt>
</div><a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line"> </tt>
<a name="PolygonInteractor.button_release_callback"></a><div id="PolygonInteractor.button_release_callback-def"><a name="L91"></a><tt class="py-lineno"> 91</tt> <a class="py-toggle" href="#" id="PolygonInteractor.button_release_callback-toggle" onclick="return toggle('PolygonInteractor.button_release_callback');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="octant.extern.poly_editor.PolygonInteractor-class.html#button_release_callback">button_release_callback</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">event</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PolygonInteractor.button_release_callback-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PolygonInteractor.button_release_callback-expanded"><a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line">        <tt class="py-docstring">'whenever a mouse button is released'</tt> </tt>
<a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-21" class="py-name"><a title="octant.extern.poly_editor.PolygonInteractor.showverts" class="py-name" href="#" onclick="return doclink('link-21', 'showverts', 'link-2');">showverts</a></tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> </tt>
<a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">button</tt> <tt class="py-op">!=</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_ind</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
</div><a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line"> </tt>
<a name="PolygonInteractor.key_press_callback"></a><div id="PolygonInteractor.key_press_callback-def"><a name="L97"></a><tt class="py-lineno"> 97</tt> <a class="py-toggle" href="#" id="PolygonInteractor.key_press_callback-toggle" onclick="return toggle('PolygonInteractor.key_press_callback');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="octant.extern.poly_editor.PolygonInteractor-class.html#key_press_callback">key_press_callback</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">event</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PolygonInteractor.key_press_callback-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PolygonInteractor.key_press_callback-expanded"><a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line">        <tt class="py-docstring">'whenever a key is pressed'</tt> </tt>
<a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">inaxes</tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> </tt>
<a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">key</tt><tt class="py-op">==</tt><tt class="py-string">'t'</tt><tt class="py-op">:</tt> </tt>
<a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-22" class="py-name"><a title="octant.extern.poly_editor.PolygonInteractor.showverts" class="py-name" href="#" onclick="return doclink('link-22', 'showverts', 'link-2');">showverts</a></tt> <tt class="py-op">=</tt> <tt class="py-keyword">not</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-23" class="py-name"><a title="octant.extern.poly_editor.PolygonInteractor.showverts" class="py-name" href="#" onclick="return doclink('link-23', 'showverts', 'link-2');">showverts</a></tt> </tt>
<a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt><tt class="py-op">.</tt><tt class="py-name">set_visible</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-24" class="py-name"><a title="octant.extern.poly_editor.PolygonInteractor.showverts" class="py-name" href="#" onclick="return doclink('link-24', 'showverts', 'link-2');">showverts</a></tt><tt class="py-op">)</tt> </tt>
<a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-25" class="py-name"><a title="octant.extern.poly_editor.PolygonInteractor.showverts" class="py-name" href="#" onclick="return doclink('link-25', 'showverts', 'link-2');">showverts</a></tt><tt class="py-op">:</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_ind</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
<a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">key</tt><tt class="py-op">==</tt><tt class="py-string">'d'</tt><tt class="py-op">:</tt> </tt>
<a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">            <tt class="py-name">ind</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-26" class="py-name"><a title="octant.extern.poly_editor.PolygonInteractor.get_ind_under_point" class="py-name" href="#" onclick="return doclink('link-26', 'get_ind_under_point', 'link-20');">get_ind_under_point</a></tt><tt class="py-op">(</tt><tt class="py-name">event</tt><tt class="py-op">)</tt> </tt>
<a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">ind</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
<a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">tup</tt> <tt class="py-keyword">for</tt> <tt class="py-name">i</tt><tt class="py-op">,</tt><tt class="py-name">tup</tt> <tt class="py-keyword">in</tt> <tt class="py-name">enumerate</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt><tt class="py-op">)</tt> <tt class="py-keyword">if</tt> <tt class="py-name">i</tt><tt class="py-op">!=</tt><tt class="py-name">ind</tt><tt class="py-op">]</tt> </tt>
<a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line">                <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt><tt class="py-op">.</tt><tt class="py-name">set_data</tt><tt class="py-op">(</tt><tt class="py-name">zip</tt><tt class="py-op">(</tt><tt class="py-op">*</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">key</tt><tt class="py-op">==</tt><tt class="py-string">'i'</tt><tt class="py-op">:</tt> </tt>
<a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line">            <tt class="py-name">xys</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">get_transform</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">transform</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt><tt class="py-op">)</tt> </tt>
<a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line">            <tt class="py-name">p</tt> <tt class="py-op">=</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt id="link-27" class="py-name"><a title="octant.grid.BoundaryInteractor.x
octant.grid.CGrid.x" class="py-name" href="#" onclick="return doclink('link-27', 'x', 'link-4');">x</a></tt><tt class="py-op">,</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt id="link-28" class="py-name"><a title="octant.grid.BoundaryInteractor.y
octant.grid.CGrid.y" class="py-name" href="#" onclick="return doclink('link-28', 'y', 'link-5');">y</a></tt> <tt class="py-comment"># display coords</tt> </tt>
<a name="L112"></a><tt class="py-lineno">112</tt>  <tt class="py-line">            <tt class="py-keyword">for</tt> <tt class="py-name">i</tt> <tt class="py-keyword">in</tt> <tt class="py-name">range</tt><tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">xys</tt><tt class="py-op">)</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line">                <tt class="py-name">s0</tt> <tt class="py-op">=</tt> <tt class="py-name">xys</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">]</tt> </tt>
<a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line">                <tt class="py-name">s1</tt> <tt class="py-op">=</tt> <tt class="py-name">xys</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line">                <tt class="py-name">d</tt> <tt class="py-op">=</tt> <tt class="py-name">dist_point_to_segment</tt><tt class="py-op">(</tt><tt class="py-name">p</tt><tt class="py-op">,</tt> <tt class="py-name">s0</tt><tt class="py-op">,</tt> <tt class="py-name">s1</tt><tt class="py-op">)</tt> </tt>
<a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">d</tt><tt class="py-op">&lt;=</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-29" class="py-name"><a title="octant.extern.poly_editor.PolygonInteractor.epsilon" class="py-name" href="#" onclick="return doclink('link-29', 'epsilon', 'link-3');">epsilon</a></tt><tt class="py-op">:</tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line">                    <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt> <tt class="py-op">=</tt> <tt class="py-name">npy</tt><tt class="py-op">.</tt><tt class="py-name">array</tt><tt class="py-op">(</tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line">                        <tt class="py-name">list</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-name">i</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> </tt>
<a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line">                        <tt class="py-op">[</tt><tt class="py-op">(</tt><tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">xdata</tt><tt class="py-op">,</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">ydata</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> <tt class="py-op">+</tt> </tt>
<a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line">                        <tt class="py-name">list</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt><tt class="py-op">[</tt><tt class="py-name">i</tt><tt class="py-op">:</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line">                    <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt><tt class="py-op">.</tt><tt class="py-name">set_data</tt><tt class="py-op">(</tt><tt class="py-name">zip</tt><tt class="py-op">(</tt><tt class="py-op">*</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line">                    <tt class="py-keyword">break</tt> </tt>
<a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line"> </tt>
<a name="L124"></a><tt class="py-lineno">124</tt>  <tt class="py-line"> </tt>
<a name="L125"></a><tt class="py-lineno">125</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">canvas</tt><tt class="py-op">.</tt><tt class="py-name">draw</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L126"></a><tt class="py-lineno">126</tt>  <tt class="py-line"> </tt>
<a name="PolygonInteractor.motion_notify_callback"></a><div id="PolygonInteractor.motion_notify_callback-def"><a name="L127"></a><tt class="py-lineno">127</tt> <a class="py-toggle" href="#" id="PolygonInteractor.motion_notify_callback-toggle" onclick="return toggle('PolygonInteractor.motion_notify_callback');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="octant.extern.poly_editor.PolygonInteractor-class.html#motion_notify_callback">motion_notify_callback</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">event</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="PolygonInteractor.motion_notify_callback-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="PolygonInteractor.motion_notify_callback-expanded"><a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line">        <tt class="py-docstring">'on mouse movement'</tt> </tt>
<a name="L129"></a><tt class="py-lineno">129</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-30" class="py-name"><a title="octant.extern.poly_editor.PolygonInteractor.showverts" class="py-name" href="#" onclick="return doclink('link-30', 'showverts', 'link-2');">showverts</a></tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> </tt>
<a name="L130"></a><tt class="py-lineno">130</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_ind</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> </tt>
<a name="L131"></a><tt class="py-lineno">131</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">inaxes</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> </tt>
<a name="L132"></a><tt class="py-lineno">132</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">button</tt> <tt class="py-op">!=</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> <tt class="py-keyword">return</tt> </tt>
<a name="L133"></a><tt class="py-lineno">133</tt>  <tt class="py-line">        <tt id="link-31" class="py-name"><a title="octant.grid.BoundaryInteractor.x
octant.grid.CGrid.x" class="py-name" href="#" onclick="return doclink('link-31', 'x', 'link-4');">x</a></tt><tt class="py-op">,</tt><tt id="link-32" class="py-name"><a title="octant.grid.BoundaryInteractor.y
octant.grid.CGrid.y" class="py-name" href="#" onclick="return doclink('link-32', 'y', 'link-5');">y</a></tt> <tt class="py-op">=</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">xdata</tt><tt class="py-op">,</tt> <tt class="py-name">event</tt><tt class="py-op">.</tt><tt class="py-name">ydata</tt> </tt>
<a name="L134"></a><tt class="py-lineno">134</tt>  <tt class="py-line"> </tt>
<a name="L135"></a><tt class="py-lineno">135</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt><tt class="py-op">[</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_ind</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt id="link-33" class="py-name"><a title="octant.grid.BoundaryInteractor.x
octant.grid.CGrid.x" class="py-name" href="#" onclick="return doclink('link-33', 'x', 'link-4');">x</a></tt><tt class="py-op">,</tt><tt id="link-34" class="py-name"><a title="octant.grid.BoundaryInteractor.y
octant.grid.CGrid.y" class="py-name" href="#" onclick="return doclink('link-34', 'y', 'link-5');">y</a></tt> </tt>
<a name="L136"></a><tt class="py-lineno">136</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt><tt class="py-op">.</tt><tt class="py-name">set_data</tt><tt class="py-op">(</tt><tt class="py-name">zip</tt><tt class="py-op">(</tt><tt class="py-op">*</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">.</tt><tt class="py-name">xy</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L137"></a><tt class="py-lineno">137</tt>  <tt class="py-line"> </tt>
<a name="L138"></a><tt class="py-lineno">138</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">canvas</tt><tt class="py-op">.</tt><tt class="py-name">restore_region</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">background</tt><tt class="py-op">)</tt> </tt>
<a name="L139"></a><tt class="py-lineno">139</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">draw_artist</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">poly</tt><tt class="py-op">)</tt> </tt>
<a name="L140"></a><tt class="py-lineno">140</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">draw_artist</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">line</tt><tt class="py-op">)</tt> </tt>
<a name="L141"></a><tt class="py-lineno">141</tt>  <tt class="py-line">        <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">canvas</tt><tt class="py-op">.</tt><tt class="py-name">blit</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">bbox</tt><tt class="py-op">)</tt> </tt>
</div></div><a name="L142"></a><tt class="py-lineno">142</tt>  <tt class="py-line"> </tt>
<a name="L143"></a><tt class="py-lineno">143</tt>  <tt class="py-line"> </tt>
<a name="L144"></a><tt class="py-lineno">144</tt>  <tt class="py-line"><tt class="py-keyword">if</tt> <tt class="py-name">__name__</tt> <tt class="py-op">==</tt> <tt class="py-string">'__main__'</tt><tt class="py-op">:</tt> </tt>
<a name="L145"></a><tt class="py-lineno">145</tt>  <tt class="py-line"> </tt>
<a name="L146"></a><tt class="py-lineno">146</tt>  <tt class="py-line">    <tt class="py-keyword">from</tt> <tt class="py-name">pylab</tt> <tt class="py-keyword">import</tt> <tt class="py-op">*</tt> </tt>
<a name="L147"></a><tt class="py-lineno">147</tt>  <tt class="py-line"> </tt>
<a name="L148"></a><tt class="py-lineno">148</tt>  <tt class="py-line">    <tt class="py-name">fig</tt> <tt class="py-op">=</tt> <tt class="py-name">figure</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L149"></a><tt class="py-lineno">149</tt>  <tt class="py-line">    <tt class="py-name">theta</tt> <tt class="py-op">=</tt> <tt class="py-name">arange</tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">,</tt> <tt class="py-number">2</tt><tt class="py-op">*</tt><tt id="link-35" class="py-name" targets="Variable octant.ocean.depths.pi=octant.ocean.depths-module.html#pi,Variable octant.ocean.pi=octant.ocean-module.html#pi,Variable octant.ocean.state.pi=octant.ocean.state-module.html#pi,Variable octant.ocean.step3d_t.pi=octant.ocean.step3d_t-module.html#pi,Variable octant.ocean.time.pi=octant.ocean.time-module.html#pi,Variable octant.ocean.velocity.pi=octant.ocean.velocity-module.html#pi"><a title="octant.ocean.depths.pi
octant.ocean.pi
octant.ocean.state.pi
octant.ocean.step3d_t.pi
octant.ocean.time.pi
octant.ocean.velocity.pi" class="py-name" href="#" onclick="return doclink('link-35', 'pi', 'link-35');">pi</a></tt><tt class="py-op">,</tt> <tt class="py-number">0.1</tt><tt class="py-op">)</tt> </tt>
<a name="L150"></a><tt class="py-lineno">150</tt>  <tt class="py-line">    <tt class="py-name">r</tt> <tt class="py-op">=</tt> <tt class="py-number">1.5</tt> </tt>
<a name="L151"></a><tt class="py-lineno">151</tt>  <tt class="py-line"> </tt>
<a name="L152"></a><tt class="py-lineno">152</tt>  <tt class="py-line">    <tt class="py-name">xs</tt> <tt class="py-op">=</tt> <tt class="py-name">r</tt><tt class="py-op">*</tt><tt class="py-name">npy</tt><tt class="py-op">.</tt><tt id="link-36" class="py-name" targets="Variable octant.ocean.cos=octant.ocean-module.html#cos,Variable octant.ocean.depths.cos=octant.ocean.depths-module.html#cos,Variable octant.ocean.state.cos=octant.ocean.state-module.html#cos,Variable octant.ocean.step3d_t.cos=octant.ocean.step3d_t-module.html#cos,Variable octant.ocean.time.cos=octant.ocean.time-module.html#cos,Variable octant.ocean.velocity.cos=octant.ocean.velocity-module.html#cos"><a title="octant.ocean.cos
octant.ocean.depths.cos
octant.ocean.state.cos
octant.ocean.step3d_t.cos
octant.ocean.time.cos
octant.ocean.velocity.cos" class="py-name" href="#" onclick="return doclink('link-36', 'cos', 'link-36');">cos</a></tt><tt class="py-op">(</tt><tt class="py-name">theta</tt><tt class="py-op">)</tt> </tt>
<a name="L153"></a><tt class="py-lineno">153</tt>  <tt class="py-line">    <tt class="py-name">ys</tt> <tt class="py-op">=</tt> <tt class="py-name">r</tt><tt class="py-op">*</tt><tt class="py-name">npy</tt><tt class="py-op">.</tt><tt id="link-37" class="py-name" targets="Variable octant.ocean.depths.sin=octant.ocean.depths-module.html#sin,Variable octant.ocean.sin=octant.ocean-module.html#sin,Variable octant.ocean.state.sin=octant.ocean.state-module.html#sin,Variable octant.ocean.step3d_t.sin=octant.ocean.step3d_t-module.html#sin,Variable octant.ocean.time.sin=octant.ocean.time-module.html#sin,Variable octant.ocean.velocity.sin=octant.ocean.velocity-module.html#sin"><a title="octant.ocean.depths.sin
octant.ocean.sin
octant.ocean.state.sin
octant.ocean.step3d_t.sin
octant.ocean.time.sin
octant.ocean.velocity.sin" class="py-name" href="#" onclick="return doclink('link-37', 'sin', 'link-37');">sin</a></tt><tt class="py-op">(</tt><tt class="py-name">theta</tt><tt class="py-op">)</tt> </tt>
<a name="L154"></a><tt class="py-lineno">154</tt>  <tt class="py-line"> </tt>
<a name="L155"></a><tt class="py-lineno">155</tt>  <tt class="py-line">    <tt class="py-name">poly</tt> <tt class="py-op">=</tt> <tt class="py-name">Polygon</tt><tt class="py-op">(</tt><tt class="py-name">zip</tt><tt class="py-op">(</tt><tt class="py-name">xs</tt><tt class="py-op">,</tt> <tt class="py-name">ys</tt><tt class="py-op">,</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-name">animated</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">)</tt> </tt>
<a name="L156"></a><tt class="py-lineno">156</tt>  <tt class="py-line"> </tt>
<a name="L157"></a><tt class="py-lineno">157</tt>  <tt class="py-line">    <tt class="py-name">ax</tt> <tt class="py-op">=</tt> <tt class="py-name">subplot</tt><tt class="py-op">(</tt><tt class="py-number">111</tt><tt class="py-op">)</tt> </tt>
<a name="L158"></a><tt class="py-lineno">158</tt>  <tt class="py-line">    <tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">add_patch</tt><tt class="py-op">(</tt><tt class="py-name">poly</tt><tt class="py-op">)</tt> </tt>
<a name="L159"></a><tt class="py-lineno">159</tt>  <tt class="py-line">    <tt class="py-name">p</tt> <tt class="py-op">=</tt> <tt id="link-38" class="py-name" targets="Class octant.extern.poly_editor.PolygonInteractor=octant.extern.poly_editor.PolygonInteractor-class.html"><a title="octant.extern.poly_editor.PolygonInteractor" class="py-name" href="#" onclick="return doclink('link-38', 'PolygonInteractor', 'link-38');">PolygonInteractor</a></tt><tt class="py-op">(</tt> <tt class="py-name">ax</tt><tt class="py-op">,</tt> <tt class="py-name">poly</tt><tt class="py-op">)</tt> </tt>
<a name="L160"></a><tt class="py-lineno">160</tt>  <tt class="py-line"> </tt>
<a name="L161"></a><tt class="py-lineno">161</tt>  <tt class="py-line">    <tt class="py-comment">#ax.add_line(p.line)</tt> </tt>
<a name="L162"></a><tt class="py-lineno">162</tt>  <tt class="py-line"><tt class="py-comment"></tt>    <tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">set_title</tt><tt class="py-op">(</tt><tt class="py-string">'Click and drag a point to move it'</tt><tt class="py-op">)</tt> </tt>
<a name="L163"></a><tt class="py-lineno">163</tt>  <tt class="py-line">    <tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">set_xlim</tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-op">-</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L164"></a><tt class="py-lineno">164</tt>  <tt class="py-line">    <tt class="py-name">ax</tt><tt class="py-op">.</tt><tt class="py-name">set_ylim</tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt class="py-op">-</tt><tt class="py-number">2</tt><tt class="py-op">,</tt><tt class="py-number">2</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L165"></a><tt class="py-lineno">165</tt>  <tt class="py-line">    <tt class="py-name">show</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L166"></a><tt class="py-lineno">166</tt>  <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="octant-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1
    on Tue May 20 16:56:06 2008
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
